package com.suitsoft.ut.entity.commons;

import java.io.File;
import java.text.DecimalFormat;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.suitsoft.ut.entity.IdEntity;
import com.suitsoft.ut.entity.thesis.Thesis;

/**
 * 上传文件信息
 *@author Suine
 */
@Entity
@Table(name = "UPDATE_FILE")
public class UploadFileInfo extends IdEntity{
	/** 论文  */
	private Thesis thesis;
	/** 本地文件名 */
	private String fileNameLocal;
	/** 远程文件名 */
	private String fileNameRemote;
	/** 本地路径 */
	private String filePathLocal;
	/** 远程路路径 */
	private String filePathRemote;
	/** 文件长度 */
	private Long fileLength;
	/** 文件大小 */
	private String fileSize;
	/** 上传时间 */
	private Date postedTime;
	/** 是否删除  */
	private Long isDeleted;
	/** 中期or 大便   1 - 中期,2 - 答辩*/
	private Long middleDabian;
	public UploadFileInfo(File file,String fileName, Thesis thesis2){
		DecimalFormat df = new DecimalFormat("#.00");
		if((file.length() / 1024 / 1024) < 1){
			this.fileSize = df.format(file.length()*1.0 /(1024)) + "KB";
		}else{
			this.fileSize = df.format(file.length()*1.0 /(1024 * 1024)) + "MB";
		}
		this.thesis = thesis2;
		this.fileLength = file.length();
		this.fileNameLocal = file.getName();
		this.fileNameRemote = fileName;
		this.filePathLocal = file.getPath();
	}
	public String getFileNameLocal() {
		return fileNameLocal;
	}
	public void setFileNameLocal(String fileNameLocal) {
		this.fileNameLocal = fileNameLocal;
	}
	public String getFileNameRemote() {
		return fileNameRemote;
	}
	public void setFileNameRemote(String fileNameRemote) {
		this.fileNameRemote = fileNameRemote;
	}
	public String getFilePathLocal() {
		return filePathLocal;
	}
	public void setFilePathLocal(String filePathLocal) {
		this.filePathLocal = filePathLocal;
	}
	public String getFilePathRemote() {
		return filePathRemote;
	}
	public void setFilePathRemote(String filePathRemote) {
		this.filePathRemote = filePathRemote;
	}
	public Long getFileLength() {
		return fileLength;
	}
	public void setFileLength(Long fileLength) {
		this.fileLength = fileLength;
	}
	public String getFileSize() {
		return fileSize;
	}
	public void setFileSize(String fileSize) {
		this.fileSize = fileSize;
	}
	public Date getPostedTime() {
		return postedTime;
	}
	public void setPostedTime(Date postedTime) {
		this.postedTime = postedTime;
	}
	public Long getIsDeleted() {
		return isDeleted;
	}
	public void setIsDeleted(Long isDeleted) {
		this.isDeleted = isDeleted;
	}
	public Long getMiddleDabian() {
		return middleDabian;
	}
	public void setMiddleDabian(Long middleDabian) {
		this.middleDabian = middleDabian;
	}
	
	public UploadFileInfo() {
	}
	@Override
	public String toString() {
		return "UploadFileInfo [thesis=" + thesis + ", fileNameLocal=" + fileNameLocal + ", fileNameRemote=" + fileNameRemote + ", filePathLocal=" + filePathLocal
				+ ", filePathRemote=" + filePathRemote + ", fileLength=" + fileLength + ", fileSize=" + fileSize + ", postedTime=" + postedTime + ", isDeleted=" + isDeleted
				+ ", middleDabian=" + middleDabian + "]";
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "THESIS_ID")
	public Thesis getThesis() {
		return thesis;
	}
	public void setThesis(Thesis thesis) {
		this.thesis = thesis;
	}
	
}

